export const esensitize = (str, start = 0, count = 1) => {
  // 参数类型校验
  if (typeof str !== 'string') {
    throw new TypeError('Expected string type for first argument');
  }
  
  // 处理负数情况
  start = Math.max(start, 0);
  count = Math.max(count, 0);

  // 边界安全处理
  const strLength = str.length;
  const end = strLength;

  // 计算实际脱敏范围
  const safeStart = Math.min(start, strLength);
  const safeCount = Math.min(count, strLength - safeStart);

  // 生成星号部分
  const mask = '*'.repeat(safeCount);

  // 拼接结果
  return str.slice(0, safeStart) + mask + str.slice(safeStart + safeCount);
};

// 验证登录状态
export const checkLogin = () => {
	const token = uni.getStorageSync('token');
	return !!token;
};
